function selectMainPersonTree(taskAssignId){
    var url=contextPath+"organ/toOrganTree.action?type=&path=toPersonTree&module=checkbox&date=12345678";
	var returnData=window.showModalDialog(url,null,"status:no;dialogWidth:650px;dialogHeight:600px;scroll:yes;");
	if(returnData){
	 	var idArr=returnData[0].split(",");
		var nameArr=returnData[1].split(",");
		$("#"+taskAssignId).empty();
	 	for (var i = 0 ; i < idArr.length ; i++) {
	 		$("#"+taskAssignId).addOption(nameArr[i],idArr[i]);
	 	}
	}
}

function selectMainPerson(taskAssignId){
    var url=contextPath+"organ/selectProdPerson.action?codeId=590";
    var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:960px;dialogHeight:640px;scroll:yes;");
	if(returnData){
		$("#"+taskAssignId).empty();
		$("#"+taskAssignId).addOption(returnData[1],returnData[0]);
	}
}

function selectMainAllPerson(taskAssignId){
    var url=contextPath+"organ/selectPerson.action";
    var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:960px;dialogHeight:640px;scroll:yes;");
	if(returnData){
		$("#"+taskAssignId).empty();
		var idArr=returnData[0].split(",");
		var nameArr=returnData[1].split(",");
		for (var i = 0 ; i < idArr.length ; i++) {
	 		$("#"+taskAssignId).addOption(nameArr[i],idArr[i]);
	 	}
		//$("#"+taskAssignId).addOption(returnData[1],returnData[0]);
	}
}

function selectProdPerson(taskAssignId){
    var url=contextPath+"organ/selectPerson.action";
    var returnData=window.showModalDialog(url,window,"status:no;dialogWidth:960px;dialogHeight:640px;scroll:yes;");
	if(returnData){
		$("#"+taskAssignId).empty();
		$("#"+taskAssignId).addOption(returnData[1],returnData[0]);
	}
}

function subValidateForm(url){
	var dForm=document.forms[0];
	dForm.action=url;
	isValid=Validator.Validate(dForm,3);
	if(isValid){
		dForm.submit();
	}
}

function subNoValidateForm(dForm,url){
		dForm.action=url;
		dForm.submit();
}

function commitSelForm(url,isCommit){
	$("#isCommitId").val(isCommit);
	var dForm=document.forms[0];
	dForm.action=url;
	var userIdArr=$("select[name='userId']");
	var count=0;
	$.each(userIdArr,function(index,obj){
		with(obj){
			objValue=options[selectedIndex].value;
			if(objValue!=''){
				count++;
			}
		}
	});
	if(count<=0){
		alert('请至少选择一个下一步骤办理人员！');
		
		return;
	}
	isValid=Validator.Validate(dForm,3);
	if(isValid){
		var fileType=$("input[name='filetype']");
		var uploads=$("input[name='uploads']");
		$.each(uploads,function(index,obj){
			if($(obj).val()==''){
				$(fileType[index]).remove();
			}
		});	
		dForm.submit();
	}
}

function commitForm(url,isCommit){
	$("#isCommitId").val(isCommit);
	var dForm=document.forms[0];
	dForm.action=url;
	isValid=Validator.Validate(dForm,3);
	if(isValid){
		var fileType=$("input[name='filetype']");
		var uploads=$("input[name='uploads']");
		$.each(uploads,function(index,obj){
			if($(obj).val()==''){
				$(fileType[index]).remove();
			}
		});	
		dForm.submit();
	}
}

function commitNotValidForm(url,isCommit){
	$("#isCommitId").val(isCommit);
	var dForm=document.forms[0];
	dForm.action=url;
	//isValid=Validator.Validate(dForm,3);
	isValid=true;
	if(isValid){
		var fileType=$("input[name='filetype']");
		var uploads=$("input[name='uploads']");
		$.each(uploads,function(index,obj){
			if($(obj).val()==''){
				$(fileType[index]).remove();
			}
		});	
		dForm.submit();
	}
}

function rollBackForm(url){
	if(confirm("你确认要回退吗？")){
		//var value=$('#commentComtentID').val();
		//var regEx=/.+/;
		//if(!regEx.test(value)){
		//	alert('请填写办理意见');
		//	$('#commentComtentID').focus();
		//	return ;
		//}
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function recyclingTaskForm(url){
	if(confirm("你确认要回收吗？")){
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function transferTaskForm(url){
	if(confirm("你确认要转派任务吗？")){
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function readToDoTaskForm(url){
	if(confirm("你确认要将任务传阅给其他人吗？")){
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function readToDoTaskFormReview(url){
	if(confirm("你确认要发起评审吗？")){
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function commitEndProcessForm(url){
	if(confirm("你确认要结束工单吗？")){
		var dForm=document.forms[0];
		dForm.action=url;
		dForm.submit();
	}
}

function commitReadToDoTaskForm(url){
	var dForm=document.forms[0];
	isValid=Validator.Validate(dForm,3);
	if(isValid){
		$("#isCommitId").val('true');
		dForm.action=url;
		dForm.submit();
	}
}

function Echoice(){};
Echoice.popCenter = function(url,w,h){
    x=w;
    y=h;
    l=(screen.width/2)-(x/2);
    t=(screen.height/2)-(y/2);
    s="toolbar=no,location=no,status=no,menubar=no,resizable=yes,scrollbars=yes";
    s+=" width=" + x + ", height=" + y + ", left=" + l + ", top=" + t;
    MRV=window.open(url,"",s);
}

//不用确认的窗口关闭
Echoice.closeWindow=function(){
	window.opener=null;
	window.open('','_self');
	window.close();
}
Echoice.showDialogMsg=function(msg,callBackFun){
	alert(msg);
	if(callBackFun){
		callBackFun.call();
	}
}

Echoice.selectOptionValue=function(selectId,selValue){
	var selOpt=$('#'+selectId+' option');
	for(i=0;i<selOpt.length;i++){
		if(selOpt[i].value==selValue){
			$(selOpt[i]).attr('selected','true');
			break;
		}
	}
}
